package org.moonlight.jvm.instructions.comparisons.ificmp;

import org.moonlight.jvm.instructions.base.BranchInstruction;
import org.moonlight.jvm.rtda.exclusive.Frame;
import org.moonlight.jvm.rtda.exclusive.OperandStack;

/**
 * IF_ICMPLE : IF_ICMPLE  指令把栈顶的两个int变量弹出，然后进行比较，满足条件则跳转。
 *            假设 栈顶的 int变量为 X, Y 那么 IF_ICMPLE  就是 Y <= X
 *
 * @author Moonlight
 * @createTime 2023/8/22 17:59
 **/
public class IfICmpLe extends BranchInstruction {
    @Override
    public void execute(Frame frame) {
        OperandStack stack = frame.getOperandStack();
        int x = stack.popInt();
        int y = stack.popInt();
        if (y <= x) {
            branch(frame);
        }
    }
}
